<{include file="Business/business_top.html" }>
<style>
	#tip{font-size: 15px;
		text-align: center;
		display: block;
		margin-top: 10px;
		margin-bottom: -13px;
		color: gray;}

	/**上传图片**/
	#up{
		position: relative;
		left: -74px;
		top: -62px;
		width: 1rem;
		height: 1rem;
		opacity: 0;

	}
	iframe{position: fixed;z-index: 10002;top: 0;background-color: white;display: none;border:none;}
</style>
</head>
<body>
<{include file="Business/business_nav.html" }>
<div id="wrap">
	<form id="form">
		<div class="consult">
			<input type="hidden" name="id" value="<{$id}>" />
			<input type="hidden" name="type" id="type" value="<{$smarty.const.OBJ_TYPE_TOY_RECORD}>"/>
			<div class="title">内容描述</div>
			<div class="textarea-box">
				<textarea id="desc" name="content" required="required"></textarea>
			</div>

			<div class="upload-box">
				<div class="upload"  id="album"></div>
				<!--<input type="file" name="file"  id="up"  >-->
			</div>
		</div>

		<input type="submit" class="submit" id="submit" value="提  交"></input>
	</form>
</div>
<iframe id="resizeImage" src="<{u('Common/resizeImage?type=IMG_COMMENT')}>" ></iframe>
<script src="<{$preStaticUrl}>js/jquery-1.11.0.js?v=<{$resVersion}>"></script>
<script src="<{$preStaticUrl}>js/jquery.ajaxfileupload.js"></script>
<script>
	var isPosting=false;
	$(function(){
		load();
		$('#form').on('submit',function(){
			if(isPosting){return false;}
			var data=$('#form').serialize();
			isPosting=true;
			$.post("<{u('comment')}>",data,function(res){
				isPosting=false;
				if(res.status==0){
					document.getElementById('form').reset();
					if(typeof res.tip !='undefined'){
						tip(res.tip,function(){location.href="<{u('matchSuccess?tradeId='|cat:$id)}>"});
					}else{
						tip("评论成功",function(){location.href="<{u('matchSuccess?tradeId='|cat:$id)}>"});
					}
					return;
				}
				tip(res.msg);

			},"json");
			return false;
		});


		//删除图片
		$(document).on("click",".delete",function(){
			$(this).parent().remove();
		});

		$('#resizeImage').css({'height':document.body.clientHeight+"px",'width':document.body.clientWidth+"px"})

	})

	function newImg(src){
		var img = '<div class="item" style="background:url('+src+') no-repeat;">'+
				'<a href="javascript:void(0);" class="delete"></a>'+
				'<input type="hidden" name="album[]" value="'+src+'" class="file"/>'+
				'</div>';
		$(".upload-box").prepend(img)
	}

	$('#album').on('click',function(){
		$('#resizeImage').show();
		$(document.getElementById('resizeImage').contentWindow.document.getElementById('file')).click()
	});
	function closeIframeResize(){
		$('#resizeImage').hide();
	}
	function load(){
		layer.open({type: 2,shadeClose:false});
	}
	function closeLoad(){
			layer.closeAll();
	}
</script>
</body>
</html>
